package com.stevenmoon.csdnplus.activity.base;

import android.os.Bundle;
import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.support.v4.view.LayoutInflaterCompat;
import android.support.v7.app.AppCompatActivity;

import com.mikepenz.iconics.context.IconicsLayoutInflater;
import com.stevenmoon.csdnplus.app.AppService;

import butterknife.ButterKnife;

/**
 * 所有基础activity的基类
 * Created by WangJun on 2016/3/28.
 */
public abstract class BaseActivity extends AppCompatActivity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        LayoutInflaterCompat.setFactory(getLayoutInflater(), new IconicsLayoutInflater(getDelegate()));
        super.onCreate(savedInstanceState);
        setContentView(getContentViewId());
        ButterKnife.bind(this);
        AppService.getInstance().getBus().register(this);
        initViews();
    }

    protected abstract void initViews() ;

    @LayoutRes protected abstract int getContentViewId();

    @Override
    protected void onDestroy() {
        super.onDestroy();
        AppService.getInstance().getBus().unregister(this);
    }
}
